package 设计mos.DecoratorPattern;

/**
 * @作者：xie
 * @时间：2022/10/11 21:08
 */
public class main {
    public static void main(String[] args) {
        Person zs = new Student();
        zs.Operation();

        System.out.println("==========");

        zs=new DecoratorA(zs);
        zs.Operation();

        //对象链
        Person lisi = new DecoratorA(new Student());
    }
}
abstract class Decorator extends Person{
    protected Person person;
}

class DecoratorA extends Decorator{
    public DecoratorA(Person person){
        this.person=person;
    }


    @Override
    public void Operation() {
        person.Operation();
        System.out.println("sb");
    }
}

abstract class Person{
    protected String name;

    public abstract void Operation();
}

class Student extends Person{

    @Override
    public void Operation() {
        System.out.println(name+"的zz：xx");
    }
}



